package com.xinqi.modules.prepare.prepare.controller.app;

import com.xinqi.common.base.response.PageInfo;
import com.xinqi.common.base.response.R;
import com.xinqi.modules.prepare.prepare.dto.req.PrepareOperateLogQueryDTO;
import com.xinqi.modules.prepare.prepare.dto.rsp.PrepareOperateLogResultDTO;
import com.xinqi.modules.prepare.prepare.service.PrepareOperateLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 备课区操作记录表APP控制层
 *
 * @author: system
 * @date: 2023/03/19
 */
@Tag(name = "prepare-operate-log-App", description = "备课区操作记录表App接口")
@RestController
@RequestMapping("/app/prepare/operate-log")
@RequiredArgsConstructor
public class PrepareOperateLogAppController {
    private final PrepareOperateLogService prepareOperateLogService;

    /**
     * 备课区操作记录表-分页
     */
    @Operation(summary = "备课区操作记录表-分页")
    @GetMapping("/page")
    public R<PageInfo<PrepareOperateLogResultDTO>> page(@ParameterObject PrepareOperateLogQueryDTO dto) {
        PageInfo<PrepareOperateLogResultDTO> page = prepareOperateLogService.page(dto, dto);
        return R.data(page);
    }

    /**
     * 备课区操作记录表-详情
     */
    @Operation(summary = "备课区操作记录表-详情")
    @GetMapping("/{id}")
    public R<PrepareOperateLogResultDTO> findById(@PathVariable("id") Long id) {
        PrepareOperateLogResultDTO dto = prepareOperateLogService.findById(id);
        return R.data(dto);
    }

    /**
     * 删除备课区操作记录表
     */
    @Operation(summary = "删除备课区操作记录表")
    @DeleteMapping("/{id}")
    public R<Boolean> delete(@Parameter(description = "id", example = "100001") @PathVariable("id") Long id) {
        return R.data(prepareOperateLogService.deleteById(id));
    }
}
